home *** CD-ROM | disk | FTP | other *** search
- program rotatevild;
- {
- VILD ROTATION #2
- - af Bjarke Viksφe
- mar 1994
-
- THIS PROGRAM WAS CODED BY BJARKE VIKS0E.
- YOU ARE FREE TO DO WHATEVER YOU WANT WITH THIS PIECE OF CODE.
- E-MAIL ME AT: dat92230@rix02.lyngbyes.dk IN 1994 FOR CHAT AND CODE.
- }
-
- {$IFDEF DPMI}
- Virker nu kun i real-mode pga. selvmodificerende kode!
- Skift til REAL-MODE!!!!!
- {$ENDIF}
-
- uses
- DEMOINIT, ILBM256;
-
- const
- DEBUG = FALSE;
- ScreenSeg = $A000;
- maxY = 300;
- c = 128;
-
- var
- i : integer;
- tabel : array[0..320] of integer;
- xpostabel : array[1..160] of integer;
- relYtabel : array[-300..300] of integer;
- sinustabel : array[0..639] of integer;
- yoff : integer;
- v : word;
- vinkel1, vinkel2 : integer;
- zpos : word;
- z : longint;
- inserted : integer;
-
- screen : pScreen;
-
- const
- display1 : integer = $0000;
- display2 : integer = $4000;
-
-
-
- (*------------------------------------------------*)
-
- procedure SwapDisplay; assembler;
- asm
- mov ax,display1
- mov dx,display2
- mov display1,dx
- mov display2,ax
-
- cli
- mov dx,$3D4
- mov al,$C
- out dx,al
- inc dx
- mov al,BYTE PTR display2+1
- out dx,al
- mov dx,$3D4
- mov al,$D
- out dx,al
- inc dx
- mov al,BYTE PTR display2
- out dx,al
- sti
- end;
-
-
-
- (*------------------------------------------------*)
-
- procedure SetupSinus;
- var
- i : integer;
- v, vadd : real;
- begin
- v:=0.0;
- vadd:=(2.0*pi/512.0);
- for i:=0 to 639 do
- begin
- sinustabel[i]:=round(sin(v)*32767);
- v:=v+vadd;
- end;
- end;
-
- procedure SetupDemo;
- var
- i : integer;
- begin
- ClearWholeScreen;
- SetupSinus;
- v:=0;
- zpos:=0;
-
- for i:=-maxy to maxy do relYtabel[i]:=i*320;
- end;
-
-
- (*------------------------------------------------*)
-
-
- procedure MakeXtabel; assembler;
- asm
- push es
-
- mov ax,ds
- mov es,ax
- lea di,xpostabel
- mov cx,160
- mov dx,2
- cld
- @makex1:
- lea si,tabel
- mov bx,dx
- mov bx,[si+bx]
- lea si,relYtabel+(maxy*2)
- sal bx,1
- mov ax,[si+bx]
- stosw
- add dx,4
- loop @makex1
-
- mov ax,ds
- mov es,ax
- lea si,tabel
- lea di,xpostabel
- mov cx,160
- cld
- @makex:
- mov ax,[si]
- add [di],ax
- add si,4
- add di,2
- loop @makex
-
- pop es
- end;
-
-
- procedure CalcVinkel;
- begin
- vinkel1:=sinustabel[v AND 511];
- vinkel2:=sinustabel[(v AND 511)+128];
- inc(v,1);
-
- z:=(sinustabel[(zpos AND 511)] DIV 15)+2700;
- inc(zpos,5);
- end;
-
-
- procedure RotateCoord(x,y : integer; VAR rx,ry : integer);
- var
- cx,cy : longint;
- begin
- cx := (longint(x)*vinkel2 - longint(y)*vinkel1) DIV 128;
- cy := (longint(x)*vinkel1 + longint(y)*vinkel2) DIV 128;
- rx := cx DIV z;
- ry := cy DIV z;
- end;
-
- (*------------------------------------------------*)
-
- procedure CalcSlope(x1,y1,x2,y2, n : integer);
- var
- x,y,delx,dely : longint;
- begin
- delx := (x2-x1) * ($10000 DIV (n-1));
- dely := (y2-y1) * ($10000 DIV (n-1));
-
- asm
- xor dx,dx
- mov ax,x1
- mov WORD PTR x,dx
- mov WORD PTR x+2,ax
- mov ax,y1
- mov WORD PTR y,dx
- mov WORD PTR y+2,ax
-
- lea si,tabel
- mov di,n
- mov ax,WORD PTR x+2
- mov dx,WORD PTR x
- mov bx,WORD PTR y+2
- mov cx,WORD PTR y
- @loop1:
- add dx,WORD PTR delx
- adc ax,WORD PTR delx+2
- mov [si],ax
- add si,2
- add cx,WORD PTR dely
- adc bx,WORD PTR dely+2
- mov [si],bx
- add si,2
- dec di
- jnz @loop1
-
- mov ax,ds
- mov es,ax
- lea si,tabel
- mov di,si
- mov cx,n
- shl cx,1
- cld
- @loop2:
- lodsw
- sar ax,7
- stosw
- loop @loop2
- end;
- end;
-
-
- procedure BigScreenRotator(x,y : integer);
- var
- XYoffset : integer;
- screenoffset : integer;
- begin
- screenoffset := display1+yoff;
-
- asm
- mov ax,y
- mov dx,320
- imul dx
- add ax,x
- mov XYoffset,ax
-
-
- cmp inserted,0
- jne @noinsert
- mov inserted,1
-
- mov ax,cs
- mov es,ax
- lea si,xpostabel
- lea di,@megaloop1+2
- cld
- mov cx,40
- @insert1:
- mov ax,[si]
- mov [es:di],ax
- add si,4
- add di,4
- mov ax,[si]
- mov [es:di],ax
- add si,4
- add di,8
- loop @insert1
-
- lea si,xpostabel+2
- lea di,@megaloop2+2
- mov cx,40
- @insert2:
- mov ax,[si]
- mov [es:di],ax
- add si,4
- add di,4
- mov ax,[si]
- mov [es:di],ax
- add si,4
- add di,8
- loop @insert2
- @noinsert:
-
- mov dx,$3C4
- mov al,$02
- out dx,al
- inc dx
- mov al,0011b
- out dx,al
-
- push ds
- push es
-
- mov si,XYoffset
- add si,WORD PTR screen
- add si,(100*320)+160
- mov di,screenoffset
- mov ax,WORD PTR screen+2
- mov ds,ax
- mov ax,ScreenSeg
- mov es,ax
- mov bx,80
- cld
- @megaloop1:
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
-
- mov dx,$3C4
- mov al,$02
- out dx,al
- inc dx
- mov al,1100b
- out dx,al
-
- mov di,screenoffset
- @megaloop2:
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- mov [es:di+bx],ax
- stosw
-
- pop es
- pop ds
- end;
- end;
-
-
- procedure RotateScreen;
- var
- x, y : integer;
- i : integer;
- begin
- yoff := 0;
- inserted := 0;
- i := 0;
- while (i<200) do
- begin
- x:=tabel[i]; y:=tabel[i+1];
- BigScreenRotator(x,y);
- inc(i,2);
- inc(yoff,width*2);
- end;
- end;
-
-
- (*------------------------------------------------*)
-
- procedure RunOnce;
- var
- i : integer;
- x1,y1, x2,y2 : integer;
- begin
- SwapDisplay;
- while retraces=0 do ;
- retraces:=0;
- if DEBUG then setrgb(0,63,0,0);
- CalcVinkel;
-
- RotateCoord(-200*c,0,x1,y1);
- RotateCoord(200*c,0,x2,y2);
- CalcSlope(x1,y1,x2,y2,160);
- MakeXtabel;
-
- RotateCoord(0,-180*c,x1,y1);
- RotateCoord(0,180*c,x2,y2);
- inc(x1,160); inc(x2,160);
- inc(y1,100); inc(y2,100);
- CalcSlope(x1,y1,x2,y2,100);
- RotateScreen;
- if DEBUG then setrgb(0,0,0,0);
- end;
-
-
- begin
- new(screen);
- LoadPix(screen, 'parasit1.lbm');
- OpenScreen;
- SetCMAP;
- SetupDemo;
- SetAllInterrupts;
- while (not KeyPressed) do RunOnce;
- RestoreAllInterrupts;
- CloseScreen;
- dispose(screen)
- end.
-